package com.ss.android.article.base.feature.detail2.video.a;

import android.view.View;
import com.ss.android.account.b.a.b;
import com.ss.android.account.model.BaseUser;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.pgc.PgcActivity;
import com.ss.android.article.base.feature.video.IVideoController;
import com.ss.android.article.browser.R;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.callback.CallbackCenter;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.newmedia.BaseAppData;
import com.ss.android.newmedia.util.AppUtil;

import org.json.JSONException;
import org.json.JSONObject;

final class h implements View.OnClickListener {
    private final VideoDetailExtraHolder a;

    h(VideoDetailExtraHolder arg1) {
        this.a = arg1;

    }

    public final void onClick(View arg12) {
        VideoDetailExtraHolder.g$a v0_3;
        JSONObject v8;
        CallbackCenter.notifyCallback(IVideoController.STOP_END_COVER, new Object[0]);
        int v0 = arg12.getId();
        if(v0 == R.id.digg_layout) {
            this.a.b(true);
            return;
        }

        if(v0 == R.id.bury_layout) {
            this.a.b(false);
            return;
        }

        if(v0 != R.id.expand_btn && v0 != R.id.video_title) {
            if(v0 != R.id.pgc_name && v0 != R.id.pgc_avatar) {
                if(v0 == R.id.subscribe_btn) {
                    VideoDetailExtraHolder v10 = this.a;
                    long v2 = 0;
                    boolean v9 = v10.f == null || v10.f.entryItem == null ? false : v10.f.entryItem.isSubscribed();
                    if(v10.mArticle != null && v10.mArticle.getUserId() > 0) {
                        v2 = v10.mArticle.getUserId();
                    }

                    if(v2 <= 0) {
                        return;
                    }

                    BaseUser v1 = new BaseUser(v2);
                    v1.mNewSource = "31";
                    b v0_1 = b.a(v10.mContext);
                    boolean v2_1 = !v9 ? true : false;
                    if(!v0_1.a(v1, v2_1, null, v0_1.a, true)) {
                        return;
                    }

                    if(v10.f == null) {
                        return;
                    }

                    if(v10.f.entryItem == null) {
                        return;
                    }

                    v10.f.entryItem.mIsLoading = true;
                    v10.a();
                    String v3 = !v9 ? "detail_subscribe_pgc" : "detail_unsubscribe_pgc";
                    if(v10.mArticle.mediaInfo == null) {
                        return;
                    }

                    v8 = new JSONObject();
                    try {
                        v8.put("item_id", v10.mArticle.itemId);
                    }
                    catch(Exception v0_2) {
                        v0_2.printStackTrace();
                    }

                    if(AppData.getInstance().getAbSettings().isAppLogOld()) {
                        MobClickCombiner.onEvent(v10.mContext, "video", v3, v10.mArticle.mediaInfo.id, 0, v8);
                    }

                    if(!AppData.getInstance().getAbSettings().isAppLogNew()) {
                        return;
                    }

                    CallbackCenter.notifyCallback(BaseAppData.callbackTypeVideoSubOrUnsub, new Object[]{BaseAppData.callbackTypeVideoSubOrUnsub, Boolean.valueOf(v9), v10.mArticle});
                }
                else {
                    if(v0 == R.id.cover_play_icon) {
                        if(this.a.K == null) {
                            return;
                        }
                        v0_3 = this.a.K;
                        v0_3.a.a(1, v0_3.a.mNewVideoFragmentHelper);
                        if(v0_3.a.mNewVideoFragmentHelper.m) {
                            return;
                        }

                        if(!NetworkUtils.isNetworkAvailable(v0_3.a.getContext())) {
                            return;
                        }

                        v0_3.a.u();
                        return;
                    }

                    if(v0 == R.id.cover_back) {
                        if(this.a.K == null) {
                            return;
                        }

                        v0_3 = this.a.K;
                        try {
                            v8 = new JSONObject();
                            v8.put("enter_from", v0_3.a.getEnterFrom());
                            MobClickCombiner.onEvent(v0_3.a.context, "detail", "page_close_button", v0_3.a.f, 0, v8);
                        }
                        catch(JSONException v1_1) {
                        }

                        v0_3.a.p();
                        return;
                    }

                    if(v0 == R.id.praise_btn) {
                        if(this.a.K == null) {
                            return;
                        }

                        VideoDetailExtraHolder.g$a v1_2 = this.a.K;
                        if(v1_2.a.mArticleDetail == null) {
                            return;
                        }

                        if(v1_2.a.mArticleDetail.praiseData == null) {
                            return;
                        }

                        if(android.support.design.a.isTextEmpty(v1_2.a.mArticleDetail.praiseData.selectLink)) {
                            return;
                        }

                        AppUtil.b(v1_2.a.getActivity(), v1_2.a.mArticleDetail.praiseData.selectLink);
                        return;
                    }

                    if(v0 == R.id.third_partner_image_view) {
                        if(this.a.K == null) {
                            return;
                        }

                        this.a.K.a.e(false);
                        return;
                    }

                    if(v0 == R.id.iv_wechat) {
                        if(this.a.K == null) {
                            return;
                        }

                        this.a.K.a(2);
                        return;
                    }

                    if(v0 == R.id.iv_moment) {
                        if(this.a.K == null) {
                            return;
                        }

                        this.a.K.a(1);
                        return;
                    }

                    if(v0 != R.id.iv_qq) {
                        return;
                    }

                    if(this.a.K == null) {
                        return;
                    }

                    this.a.K.a(3);
                }

                return;
            }

            if(this.a.f == null) {
                return;
            }

            if(this.a.f.id <= 0) {
                return;
            }

            if(this.a.mArticle == null) {
                return;
            }

            PgcActivity.startActivity(this.a.mContext, this.a.f.id, this.a.mArticle.itemId, "video_article_top_author");
            this.a.b("detail_enter_pgc");
            return;
        }

        if(this.a.mExpandBtn != null && this.a.mExpandBtn.getVisibility() == View.VISIBLE) {
            VideoDetailExtraHolder v1_3 = this.a;
            String v0_4 = !this.a.M ? "detail_unfold_content" : "detail_fold_content";
            v1_3.b(v0_4);
            v1_3 = this.a;
            boolean v0_5 = !this.a.M ? true : false;
            v1_3.a(v0_5);
        }
    }
}

